package net.knightwatch.kwtools.database; 

import net.knightwatch.kwtools.walkthrough.items.Answer;
import android.content.ContentValues;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class AnswerTypeTable {
	// Class Information
				private static final String TAG = "AnswerTypeTable";
				// Database Table
				public static final String TABLE_ANSWER_TYPE = "AnswerTypes";
				public static final String COLUMN_ID = "_id";
				public static final String COLUMN_TYPE = "type";
				
				// Database Creation SQL Statement
				private static final String DATABASE_CREATE = "create table " 
						+ TABLE_ANSWER_TYPE
						+ "("
						+ COLUMN_ID + " integer primary key autoincrement,"
						+ COLUMN_TYPE + " text not null"
						+ ");";
				
				public static void onCreate(SQLiteDatabase database) {
					
					try {
						Log.i(TAG, "Creating " + TABLE_ANSWER_TYPE + " Table");
						Log.d(TAG, DATABASE_CREATE);
						database.execSQL(DATABASE_CREATE);
						// Create the default options
						Log.i(TAG, "Creating default values");
						createDefaultValues(database);
					} catch (SQLException e) {
						e.printStackTrace();
					} finally {
						Log.i(TAG, "Table " + TABLE_ANSWER_TYPE + " has been created. Default values have been loaded.");
					}
					
				}
				private static void createDefaultValues(SQLiteDatabase database) {
					ContentValues values = new ContentValues();
					values.clear();
					values.put(COLUMN_ID, Answer.AUTOCOMPLETE_TYPE);
					values.put(COLUMN_TYPE, "Auto Complete Type");
					database.insert(TABLE_ANSWER_TYPE, null, values);
					values.clear();
					values.put(COLUMN_ID, Answer.BOOLEAN_TYPE);
					values.put(COLUMN_TYPE, "Boolean Type");
					database.insert(TABLE_ANSWER_TYPE, null, values);
					values.clear();
					values.put(COLUMN_ID, Answer.PHOTO_TYPE);
					values.put(COLUMN_TYPE, "Photo Type");
					database.insert(TABLE_ANSWER_TYPE, null, values);
					values.clear();
					values.put(COLUMN_ID, Answer.SPINNER_TYPE);
					values.put(COLUMN_TYPE, "Pick List Type");
					database.insert(TABLE_ANSWER_TYPE, null, values);
					values.clear();
					values.put(COLUMN_ID, Answer.TEXT_TYPE);
					values.put(COLUMN_TYPE, "Text Type");
					database.insert(TABLE_ANSWER_TYPE, null, values);
					values.clear();
					values.put(COLUMN_ID, Answer.RADIOBUTTON_TYPE);
					values.put(COLUMN_TYPE, "Radio Button Type");
					database.insert(TABLE_ANSWER_TYPE, null, values);
					values.clear();
				}
				public static void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion){
					
				}
}
